<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Menu_model extends CI_Model {

	 var $table = 'menu';
   public function __construct()
   {
    parent::__construct();
   }

   //Lấy dữ liệu menu_top phần public
   public function menu($menuType){
      $query = 'select menuId, menuName, menuLink from menu where menuStatus =1 AND menuChild =0 AND menuType = :menuType order by menuSort asc';
      $statement = $this->db->prepare($query);
      $statement->bindValue(':menuType', $menuType);
      $statement->execute();
      $results = $statement->fetchAll(PDO::FETCH_ASSOC);
      $statement->closeCursor();
      return $results;
   }
   public function menuChild($menuChild,$menuType){
      $query = 'select menuName, menuLink, menuChild,en from menu where menuStatus =1 and menuChild = :menuChild and menuType = :menuType order by menuSort asc';
   	$statement = $this->db->prepare($query);
      $statement->bindValue(':menuChild', $menuChild);
      $statement->bindValue(':menuType', $menuType);
      $statement->execute();
      $results = $statement->fetchAll(PDO::FETCH_ASSOC);
      $statement->closeCursor();
      return $results;  
   }

/*
   public function chart(){
      $this->db->select('votedDate, votedNum');
      $this->db->from('ksv_chart');
      $this->db->order_by('votedDate asc');
      $this->db->limit('100');
       $query = $this->db->get()->result_array();
      return $query;
   }*/
}
?>